﻿using CommunityToolkit.Mvvm.ComponentModel;
using CommunityToolkit.Mvvm.Input;
using DataShower.Interfaces;
using DataShower.Models;
using DataShower.Services;

namespace DataShower.ViewModels;

partial class LoginWindowViewModel : ObservableObject
{
    [ObservableProperty]
    DateTime time = DateTime.Now;

    [ObservableProperty]
    string name = string.Empty;

    [ObservableProperty]
    string company = string.Empty;

    [RelayCommand]
    void Close(IWindowManager manager)
    {
        manager?.CloseDialog(false);
    }

    [RelayCommand]
    void Login(IWindowManager manager)
    {
        User user = User.Current;
        user.Name = Name;
        user.Company = Company;
        user.Time = Time;

        bool isValid = UserVerifyService.Check(user);
        manager.CloseDialog(isValid);
    }
}